<template>
  <div>
    <h3>LifeCircle组件 count值{{count}}</h3>
    <button @click="Add" >+1</button>
  </div>
</template>

<script>
import { onMounted } from 'vue';

export default {
    name:'LifeCircle',
    emits:['add'],
data(){
    return{
        count:1
    }
},
methods:{
    Add(){
        this.count+=1;
        this.$emit('add',this.count)
    }
},

    // 生命周期函数
    // 组件在内存中被创建
    created(){
        console.log('created:组件在内存中被创建');
    },
    // 组件被渲染到了页面上
    mounted(){
        console.log('mounted:组件被渲染到了页面上');
    },
    // 组件被销毁
    unmounted(){
        console.log('unmounted:组件被销毁');
    },
    // 组件被重新渲染
    updated(){
        console.log('updated:组件被重新渲染');
    }

}
</script>

<style>

</style>